 #ifndef ANIMATORWIDGET_H
 #define ANIMATORWIDGET_H
 
#include <QWidget>
#include <QPushButton>
#include <QSlider>
#include <QLabel>
#include <QCheckBox>
#include <QGridLayout>
#include <QTimer>
#include <QList>

class QSlider;
class GLWidget;
class Robot;
class Core;
class AnimationLabel;


class animatorWidget : public QWidget
{
	Q_OBJECT

public:
	animatorWidget(Robot *robot, Core *core);
	void setTabIndex(int index);
	
public slots:
	void robotLoaded();
	void tabSelected(int index);
	
signals:
	void changePlayPriority(int);

private slots:
	void stopAnimation();
	void playAnimation();
	void nextAnimation();
	void prevAnimation();
	void loopAnimations();
// 	void setSpeed(int speed);
	void stepAnimations();
	void firstAnimation();
	void lastAnimation();
	
	void animationTick();
	
	void playPriorityChanged(int priority);
	
private:
	void pushJoints();
	void popJoints();
	void generateAnimationLabels();
	void initializeJoints();
	
	int timeout;
	int tabIndex;
	bool tabIsOpen;
	
	int mode;	// 0 = reset , 1 = stopped , 2 = playing , 3 = paused, 4 = stopped at end
	int currentAnimationLevel;
	
	bool canPlay;
	int currentPlayPriority;
	
	QList<float>	jointValuesList;
	QList<AnimationLabel*> animationLabelList;
	AnimationLabel *aniLabel;
	
	GLWidget *glWidget;
	Robot *robotPointer;
	Core *corePointer;
	
	QTimer *timer;
	
	QGridLayout *mainLayout;
	QVBoxLayout *animationsLayout;
	QHBoxLayout *buttonsLayout;
	
	QSlider *speedSlider;
	QLabel *sliderLabel;
	
	QPushButton *stopButton;
	QPushButton *playButton;
	QPushButton *nextButton;
	QPushButton *prevButton;
	QPushButton *loopButton;
	QPushButton *stepButton;
	QPushButton *firstButton;
	QPushButton *lastButton;
	
	bool stepThruAnimations;
	bool loopAllAnimations;
 };

#endif
